package com.hrzyit.whistle.cases.presenter

import com.hrzyit.base.ext.execute
import com.hrzyit.base.presenter.BasePresenter
import com.hrzyit.base.rx.BaseObserver
import com.hrzyit.whistle.cases.data.bean.CaseIndexDeptInfoVo
import com.hrzyit.whistle.cases.presenter.view.TransferSelectDeptView
import com.hrzyit.whistle.cases.service.ICaseCenterService
import javax.inject.Inject

/**
 * 案件管理-批转单位操作 Presenter
 * @author YangWei
 * @date 2019/4/20
 */
class TransferSelectDeptPresenter @Inject constructor():BasePresenter<TransferSelectDeptView>() {

    @Inject
    lateinit var caseCenterService: ICaseCenterService

    /**
     * 获取批转单位信息列表
     * @author YangWei
     * @date 2019/4/19
     * @param caseId   案件id
     * @param userId   操作人id
     * @return 批转单位信息列表 @{link CaseIndexDeptInfoVo}
     */
    fun selectCaseTransferDeptList(caseId: Long, userId: Long) {
        if (!checkNetWork()) {
            return
        }

        // 显示进度框
        mView.showLoading()

        caseCenterService.selectCaseTransferDeptList(caseId, userId)
            .execute(object : BaseObserver<MutableList<CaseIndexDeptInfoVo>>(mView) {
                override fun onNext(t: MutableList<CaseIndexDeptInfoVo>) {
                    mView.onGetSelectCaseTransferDeptListSuccess(t)
                }
            }, lifecycleProvider)
    }

    /**
     * 保存单位批转案件信息（单位->单位）
     * @author YangWei
     * @date 2019/4/20
     * @param caseId   案件id
     * @param userId   操作人id
     * @param disposeDeptId   处置单位id
     * @param disposeUserId   处置人id
     * @return 成功(true)|失败(false)
     */
    fun saveTransferCaseToDept(caseId: Long, userId: Long, disposeDeptId: Long, disposeUserId: Long) {
        if (!checkNetWork()) {
            return
        }

        // 显示进度框
        mView.showLoading()

//        caseCenterService.saveTransferCaseToDept(caseId, userId, disposeDeptId, disposeUserId)
//            .execute(object : BaseObserver<Boolean>(mView) {
//                override fun onNext(t: Boolean) {
//                    mView.onSaveCaseDisposeUserSuccess(t)
//                }
//            }, lifecycleProvider)
    }

}